package com.atguigu.yygh.cmn.controller;

import com.atguigu.yygh.cmn.service.DictService;
import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.model.cmn.Dict;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author study
 * @version 1.0
 * @date 2021/5/6 15:53
 */
@Api(tags = "数据字典管理")
@RestController
@RequestMapping("/admin/cmn/dict")
public class DictController {
    @Autowired
    private DictService dictService;

    //查询数据字典表所以信息
    @ApiOperation(value = "根据数据ID获取子数据列表")
    @GetMapping("findChildData/{id}")
    public Result findAllHospital(@PathVariable Long id) {
        final List<Dict> list = dictService.findChildData(id);
        return Result.ok(list);
    }


    //根据dictcode 查询
    @GetMapping("getName/{dictCode}/{value}")
    public String getName(
            @PathVariable String dictCode,
            @PathVariable String value) {
        String name = dictService.getDicName(dictCode, value);
        return name;
    }
}
